package com.niit.service;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private Button btnStart;

    private Button btnStop;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        btnStart = (Button)findViewById(R.id.startPlayer);
        btnStop = (Button)findViewById(R.id.stopPlayer);
        btnStart.setOnClickListener(this);
        btnStop.setOnClickListener(this);

        Button btnPause = (Button)findViewById(R.id.pausePlayer);
        Button btnContinue = (Button)findViewById(R.id.continuePlayer);
        btnContinue.setOnClickListener(this);
        btnPause.setOnClickListener(this);
    }

    @Override
    public void onClick(View view){
        Intent intent = new Intent();
        switch (view.getId()){
            case R.id.startPlayer:
                intent = new Intent(this,MusicService.class);
                intent.putExtra("status",0);
                startService(intent);
                btnStart.setEnabled(false);
                btnStop.setEnabled(true);
                break;

            case R.id.pausePlayer:
                intent = new Intent(this,MusicService.class);
                intent.putExtra("status",1);
                startService(intent);
                break;

            case R.id.continuePlayer:
                intent = new Intent(this,MusicService.class);
                intent.putExtra("status",2);
                startService(intent);
                break;

            case R.id.stopPlayer:
                intent = new Intent(this,MusicService.class);
                intent.putExtra("status",3);
                startService(intent);
                btnStart.setEnabled(true);
                btnStop.setEnabled(false);
                break;
        }
    }
}